package com.ruoyi.bantong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bantong.domain.BtPlacecardConfig;
import com.ruoyi.bantong.service.IBtPlacecardConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 席位卡玩法配置Controller
 * 
 * @author laohei
 * @date 2021-01-24
 */
@RestController
@RequestMapping("/bantong/config")
public class BtPlacecardConfigController extends BaseController
{
    @Autowired
    private IBtPlacecardConfigService btPlacecardConfigService;

    /**
     * 查询席位卡玩法配置列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(BtPlacecardConfig btPlacecardConfig)
    {
        startPage();
        List<BtPlacecardConfig> list = btPlacecardConfigService.selectBtPlacecardConfigList(btPlacecardConfig);
        return getDataTable(list);
    }

    /**
     * 导出席位卡玩法配置列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:config:export')")
    @Log(title = "席位卡玩法配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BtPlacecardConfig btPlacecardConfig)
    {
        List<BtPlacecardConfig> list = btPlacecardConfigService.selectBtPlacecardConfigList(btPlacecardConfig);
        ExcelUtil<BtPlacecardConfig> util = new ExcelUtil<BtPlacecardConfig>(BtPlacecardConfig.class);
        return util.exportExcel(list, "config");
    }

    /**
     * 获取席位卡玩法配置详细信息
     */
    //@PreAuthorize("@ss.hasPermi('bantong:config:query')")
    @GetMapping(value = "/{userLevel}")
    public AjaxResult getInfo(@PathVariable("userLevel") Integer userLevel)
    {
        return AjaxResult.success(btPlacecardConfigService.selectBtPlacecardConfigById(userLevel));
    }

    /**
     * 新增席位卡玩法配置
     */
    //@PreAuthorize("@ss.hasPermi('bantong:config:add')")
    @Log(title = "席位卡玩法配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BtPlacecardConfig btPlacecardConfig)
    {
        return toAjax(btPlacecardConfigService.insertBtPlacecardConfig(btPlacecardConfig));
    }

    /**
     * 修改席位卡玩法配置
     */
    //@PreAuthorize("@ss.hasPermi('bantong:config:edit')")
    @Log(title = "席位卡玩法配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BtPlacecardConfig btPlacecardConfig)
    {
        return toAjax(btPlacecardConfigService.updateBtPlacecardConfig(btPlacecardConfig));
    }

    /**
     * 删除席位卡玩法配置
     */
    //@PreAuthorize("@ss.hasPermi('bantong:config:remove')")
    @Log(title = "席位卡玩法配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userLevels}")
    public AjaxResult remove(@PathVariable Integer[] userLevels)
    {
        return toAjax(btPlacecardConfigService.deleteBtPlacecardConfigByIds(userLevels));
    }
}
